package com.feng.extra;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

//BeanFactoryPostProcessor应用在  所有bean已经被加载在容器中  但还未被初始化
/*      BeanFactoryPostProcessor application   after its standard
        * initialization. All bean definitions will have been loaded, but no beans
        * will have been instantiated yet.
        * */
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        String[] beanDefinitionNames = configurableListableBeanFactory.getBeanDefinitionNames();
        for (String name:beanDefinitionNames){
            System.out.println("我是MyBeanFactoryPostProcessor:  "+name);
        }
    }
}
